﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ProjectStorageLib.Factor
{
    public class FactorProcessor : DatabaseEntities
    {
          public FactorProcessor()
            : base()
        { }

        protected override void Dispose(bool flag)
        {
            
        }

        public void AddFactor(ProjectStorageDB.Factor factor)
        {
            try 
            {
                ent.AddToFactors(factor);
                ent.SaveChanges();
            }
            catch (Exception)
            {
                throw;
            }
        }

        public bool IsFactorExists(string factorname)
        {
            var result = (from f in ent.Factors where f.Name == factorname select f).Count();
            return (result > 0);
        }

        public void AddFactorScales(ProjectStorageDB.FactorScale scale)
        {
            try
            {
                ent.AddToFactorScales(scale);
                ent.SaveChanges();
            }
            catch (Exception)
            {
                throw;
            }

        }
    }
}
